package com.ts.api.common.util;

import com.gitee.apanlh.util.base.StringUtils;

/**
 *  H5相关域名URL工具类
 *
 *  @author Pan
 */
public class H5DomainUrlUtils {

    /** H5回调-参数 */
    static final String H5_CALL_URL = "https://axh.rongyiudai.com/h5call/timeLimit";
    static final String H5_APPLY_ID_PARAM = "applyId";
    static final String H5_CODE_PARAM = "code";

    /** 下游用户授权-参数 */
    static final String PRODUCT_USER_PROTOCOL_URL = "https://axh.rongyiudai.com/h5UserProtocol";
    static final String PRODUCT_PLAN_ID_PARAM = "pId";
    static final String PRODUCT_PHONE_MD5_PARAM = "phoneMd5";

    /**
     *  创建H5-回调授权页面
     *
     *  @param  applyId     申请id
     *  @param  apiClientId api客户端id
     *  @return String
     */
    public static String createH5CallUrl(String applyId, String apiClientId) {
        String url = StringUtils.createBuilder(H5_CALL_URL)
            .append("?").append(H5_APPLY_ID_PARAM).append("=").append(applyId)
            .append("&").append(H5_CODE_PARAM).append("=").append(apiClientId)
        .toString();
        return url;
    }

    /**
     *  创建H5-用户协议页面
     *
     *  @param  productPlanId     计划ID
     *  @param  phoneMd5          手机号MD5
     *  @return String
     */
    public static String createUserProtocolUrl(Long productPlanId, String phoneMd5) {
        String url = StringUtils.createBuilder(PRODUCT_USER_PROTOCOL_URL)
                .append("?").append(PRODUCT_PLAN_ID_PARAM).append("=").append(productPlanId)
                .append("&").append(PRODUCT_PHONE_MD5_PARAM).append("=").append(phoneMd5)
                .toString();
        return url;
    }
}
